package cn.xinzhi.dao.Impl;

import cn.xinzhi.dao.BaseDao;
import cn.xinzhi.dao.Iyh_goodsDao;
import cn.xinzhi.entity.Yh_goods;
import cn.xinzhi.entity.Yh_login;
import com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class Yh_goodsDaoImpl implements Iyh_goodsDao {
    @Override
    public int goods(String j_name, String j_numder, String j_site, String s_name, String s_numder, String s_site) {
        Connection conn = null;
        PreparedStatement stat = null;
        ResultSet rs = null;
        Yh_login login=null;
        int count =-1;
        try {
            conn = BaseDao.getConn();
            String sql = "insert into yh_goods values ( ? , ? , ? , ? , ? , ? )";
            stat = conn.prepareStatement(sql);
            stat.setString(1,j_name);
            stat.setString(2,j_numder);
            stat.setString(3,j_site);
            stat.setString(4,s_name);
            stat.setString(5,s_numder);
            stat.setString(6,s_site);
            count = stat.executeUpdate();
        } catch (MySQLIntegrityConstraintViolationException s) {
            System.out.println("用户名已存在,请重新注册或者前去登录");
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return count;
    }
}
